<?php
namespace Home\Controller;
use Think\Controller;
class QrcodeController extends Controller {
	public function index(){
		$this->display();
	}

	public function getQRPic(){
		if (IS_POST ){
			$scene_id = i("scene_id");
			$type     = i('type');
			$expire   = i('expire');

			if (!$weObj =getCache('weObj')) {
				$options = array(
		 		   'token'=>c('wxtoken'), //填写你设定的key
		 		   'encodingaeskey'=>c('encodingaeskey'), //填写加密用的EncodingAESKey
				   'appid'=>c('appid'), //填写高级调用功能的app id, 请在微信开发模式后台查询
		  		   'appsecret'=>c('appsecret') //填写高级调用功能的密钥
		  		   );
			 	$weObj = new \Org\Net\Wechat($options); //创建实例对象
        		setCache('weObj',$weObj);			 					
			};


			$data=$weObj->getQRCode($scene_id,$type,$expire);
			$ticket=$data['ticket'];
			$url=$weObj->getQRUrl($ticket);
			$this->assign('url',$url);
			$this->display();
		 	//header('location:'.$url);
		} else header("location:".u('index'));

	}
}